package com.ruoyi.system.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HotelFacilities;
import com.ruoyi.system.service.IHotelFacilitiesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 酒店设施Controller
 * 
 * @author ruoyi
 * @date 2023-05-10
 */
@RestController
@RequestMapping("/system/facilities")
public class HotelFacilitiesController extends BaseController
{
    @Autowired
    private IHotelFacilitiesService hotelFacilitiesService;

    /**
     * 查询酒店设施列表
     */
    @PreAuthorize("@ss.hasPermi('system:facilities:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelFacilities hotelFacilities)
    {
        startPage();
        List<HotelFacilities> list = hotelFacilitiesService.selectHotelFacilitiesList(hotelFacilities);
        return getDataTable(list);
    }

    /**
     * 导出酒店设施列表
     */
    @PreAuthorize("@ss.hasPermi('system:facilities:export')")
    @Log(title = "酒店设施", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelFacilities hotelFacilities)
    {
        List<HotelFacilities> list = hotelFacilitiesService.selectHotelFacilitiesList(hotelFacilities);
        ExcelUtil<HotelFacilities> util = new ExcelUtil<HotelFacilities>(HotelFacilities.class);
        util.exportExcel(response, list, "酒店设施数据");
    }

    /**
     * 获取酒店设施详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:facilities:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hotelFacilitiesService.selectHotelFacilitiesById(id));
    }

    /**
     * 新增酒店设施
     */
    @PreAuthorize("@ss.hasPermi('system:facilities:add')")
    @Log(title = "酒店设施", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelFacilities hotelFacilities)
    {
        return toAjax(hotelFacilitiesService.insertHotelFacilities(hotelFacilities));
    }

    /**
     * 修改酒店设施
     */
    @PreAuthorize("@ss.hasPermi('system:facilities:edit')")
    @Log(title = "酒店设施", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelFacilities hotelFacilities)
    {
        return toAjax(hotelFacilitiesService.updateHotelFacilities(hotelFacilities));
    }

    /**
     * 删除酒店设施
     */
    @PreAuthorize("@ss.hasPermi('system:facilities:remove')")
    @Log(title = "酒店设施", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hotelFacilitiesService.deleteHotelFacilitiesByIds(ids));
    }
}
